/*
 * @Descripttion: 
 * @version: 
 * @Author: TT
 * @Date: 2022-11-23 17:52:13
 * @LastEditors: TT
 * @LastEditTime: 2022-12-20 10:07:48
 */

import 'package:flutter/material.dart';
import 'package:hzy_normal_widget/hzy_normal_widget.dart';
import '../config/hzy_color_config.dart';
import 'common_place_holder_widget.dart';

abstract class CommonStateWidget<T extends StatefulWidget>
    extends NormalState<T> with WidgetsBindingObserver {
  CommonPlaceHoldType placeHoldType = CommonPlaceHoldType.nonetwork;

  @override
  void initDefaultState() {
    super.initDefaultState();
    WidgetsBinding.instance.addObserver(this);
  }

  @override
  void initDefaultDispose() {
    WidgetsBinding.instance.removeObserver(this); // 移除监听器
    super.initDefaultDispose();
  }

  /// 创建失败 界面
  @override
  Widget? createErrorWidget() {
    return CommonPlaceHoldPage(
      placeHoldType: placeHoldType,
      ontap: (type) {
        tapplachold(type);
      },
    );
  }

  @override
  Color? createLeadingIconColor() {
    return HzyColorConfig().col000000;
  }

  @override
  Color? createAppBarTextColor() {
    return HzyColorConfig().col000000;
  }

  void tapplachold(CommonPlaceHoldType type) {}
}
